#ifndef __CH32V_EEPROM_H__
#define __CH32V_EEPROM_H__

#include "ch32v_def.h"

#ifdef __cpluscplus
extern "C"
{
#endif

#define FLASH_PAGE_SIZE 0x400U

/* Exported macro ------------------------------------------------------------*/
#define E2END (FLASH_PAGE_SIZE - 1)
    /* Exported functions ------------------------------------------------------- */

    uint8_t eeprom_read_byte(const uint32_t pos);
    void eeprom_write_byte(uint32_t pos, uint8_t value);

    /* Prived functions ------------------------------------------------------- */
    void eeprom_buffer_fill();
    void eeprom_buffer_flush();
    uint8_t eeprom_buffered_read_byte(const uint32_t pos);
    void eeprom_buffered_write_byte(uint32_t pos, uint8_t value);

#ifdef __cpluscplus
}
#endif
#endif // __CH32V_EEPROM_H__